package edu.hunau.cxb19.oop.class05;

import java.util.Scanner;

import org.junit.Test;

import edu.hunau.cxb19.oop.class05.hk.MultiQuestion;
import edu.hunau.cxb19.oop.class05.hk.Question;
import edu.hunau.cxb19.oop.class05.hk.SingleQuestion;

/**
 *
 * @author hb
 *
 *         2020-02-28 15:24:49
 */
public class QuestionTest {

	@Test
	public void testPaper() {
		Question[] arr = new Question[2];

		// 1. 实例化一个单选题
		SingleQuestion q1 = new SingleQuestion(1, new String[] { "张", "王", "李", "不想认识" }, "面向对象编程的老师的姓氏?", 'D');
		// 2. 实例化多选
		MultiQuestion q2 = new MultiQuestion(2, new String[] { "西游记", "27天精通java", "红楼梦", "水浒传" }, "中国四大名著?",
				new char[] { 'A', 'C', 'D' });

		arr[0] = q1;
		arr[1] = q2;

		int score = 0;
		Scanner sc = new Scanner(System.in);
		for (int i = 0; i < arr.length; i++) {
			arr[i].print();
			System.out.println("输入你的答案:");
			String datas = sc.nextLine();
			//将一个字符串转成字符数组
			char[] answers = datas.toCharArray();
			if (arr[i].check(answers)) {
				score += 10;
			}
		}
		System.out.println("\t成绩为:" + score);
		
	 

	}
}
